package com.app.public_dependency.xlsx;

import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;

@Slf4j
public class ExcelFileUtil {
    public static void CreateEmptyExcelFile(String path) {
        // 创建一个新的工作簿
        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet("Sheet1");
        // 将工作簿写入文件
        try (FileOutputStream fileOut = new FileOutputStream(path)) {
            workbook.write(fileOut);
        } catch (IOException e) {
            log.error("ERROR -> " + e.getMessage());
        } finally {
            // 关闭工作簿
            try {
                workbook.close();
            } catch (IOException e) {
                log.error("ERROR -> " + e.getMessage());
            }
        }
    }
}
